package com.starlink.common;

import com.starlink.common.domain.BaseRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

/**
 * @author zhanghong
 */
@ApiModel(description = "分页查询参数")
public class PageQueryRequest extends BaseRequest {
  @ApiModelProperty(value ="页码")
  private Integer pageNum;
  @ApiModelProperty(value ="分页大小")
  private Integer pageSize;

  public Integer getPageNum() {
    if(pageNum == null || pageNum < 1){
      pageNum = 1;
    }
    return pageNum;
  }

  public void setPageNum(Integer pageNum) {
    this.pageNum = pageNum;
  }

  public Integer getPageSize() {
    if(pageSize == null || pageSize == 0){
      pageSize = 20;
    }
    return pageSize;
  }

  public void setPageSize(Integer pageSize) {
    this.pageSize = pageSize;
  }

  public int fetchOffSet(){
    return (this.getPageNum() - 1) * this.getPageSize();
  }

}
